<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : orderFO.xsl
    Created on : March 27, 2013, 5:31 PM
    Author     : duonghung1369
    Description:
        Purpose of transformation follows.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                xmlns:p="http://xml.netbeans.org/schema/profile"
                version="1.0">
    <xsl:output method="xml" indent="yes"/>

    <!-- TODO customize transformation rules 
         syntax recommendation http://www.w3.org/TR/xslt 
    -->
    <xsl:template match="/">
        <fo:root>
            <fo:layout-master-set>
                <fo:simple-page-master master-name="A4-portrait"
                        page-height="29.7cm" page-width="21.0cm" margin="2cm">
                    <fo:region-body/>
                </fo:simple-page-master>
            </fo:layout-master-set>

            <fo:page-sequence master-reference="A4-portrait">
                <fo:flow flow-name="xsl-region-body">
                    <fo:block font-size="50pt" line-height="100pt" text-align="center" color="blue">
                        AntiqueShop
                    </fo:block>

                    <fo:block font-size="25pt" line-height="50pt" color="blue">
                        Customer Information
                    </fo:block>
                    <fo:block font-family="Arial" >
                        <xsl:for-each select="//p:profile">
                            <fo:table border-style="dotted">
                                <fo:table-column/>
                                <fo:table-column/>

                                <fo:table-body>
                                    <fo:table-row>
                                        <fo:table-cell>
                                            <fo:block>Name</fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell>
                                            <fo:block>
                                                <xsl:value-of select="p:firstname"/>
                                                <xsl:text> </xsl:text>
                                                <xsl:value-of select="p:lastname" />
                                            </fo:block>
                                        </fo:table-cell>
                                    </fo:table-row>
                                    <fo:table-row>
                                        <fo:table-cell>
                                            <fo:block>Email</fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell>
                                            <fo:block>
                                                <xsl:value-of select="p:email"/>
                                            </fo:block>
                                        </fo:table-cell>
                                    </fo:table-row>
                                    <fo:table-row>
                                        <fo:table-cell>
                                            <fo:block>Phone</fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell>
                                            <fo:block>
                                                <xsl:value-of select="p:phoneNumber"/>
                                            </fo:block>
                                        </fo:table-cell>
                                    </fo:table-row>
                                    <fo:table-row>
                                        <fo:table-cell>
                                            <fo:block>Address</fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell>
                                            <fo:block>
                                                <xsl:value-of select="p:address"/>
                                            </fo:block>
                                        </fo:table-cell>
                                    </fo:table-row>
                                </fo:table-body>
                            </fo:table>
                        </xsl:for-each>
                    </fo:block>

                    <fo:block font-size="25pt" line-height="50pt" color="blue">
                        Note
                    </fo:block>
                    <fo:block >
                        <fo:table border-style="dotted">
                            <fo:table-column/>
                            <fo:table-column/>

                            <fo:table-body>
                                <fo:table-row color="red">
                                    <fo:table-cell>
                                        <fo:block>Confirmation number : </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell>
                                        <fo:block>
                                            <xsl:value-of select="//confirmation"/>
                                        </fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                                <fo:table-row>
                                    <fo:table-cell>
                                        <fo:block>Date processed : </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell>
                                        <fo:block>
                                            <xsl:value-of select="//dateprocess"/>
                                        </fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                            </fo:table-body>
                        </fo:table>
                    </fo:block>

                    <fo:block font-size="25pt" line-height="50pt" color="blue">
                        Order Details
                    </fo:block>
                    <fo:block font-family="Arial">
                        <fo:table text-align="center">
                            <fo:table-column/>
                            <fo:table-column/>
                            <fo:table-column/>

                            <fo:table-body>
                                <fo:table-row background-color="antiquewhite">
                                    <fo:table-cell border-style="solid" color="deepskyblue">
                                        <fo:block>Product</fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border-style="solid" color="deepskyblue">
                                        <fo:block>Quantity</fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border-style="solid" color="deepskyblue">
                                        <fo:block>Price ($)</fo:block>
                                    </fo:table-cell>
                                </fo:table-row>

                                <xsl:for-each select="//product">
                                    <fo:table-row>
                                        <fo:table-cell border-style="solid">
                                            <fo:block>
                                                <xsl:value-of select="name"/>
                                            </fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell border-style="solid">
                                            <fo:block>
                                                <xsl:value-of select="quantity"/>
                                            </fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell border-style="solid">
                                            <fo:block>
                                                <xsl:value-of select="subtotal"/>
                                            </fo:block>
                                        </fo:table-cell>
                                    </fo:table-row>
                                </xsl:for-each>

                                <fo:table-row background-color="aqua">
                                    <fo:table-cell border-style="solid">
                                        <fo:block> </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border-style="solid" color="red">
                                        <fo:block>Total</fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border-style="solid" color="red">
                                        <fo:block>
                                            <xsl:value-of select="//total"/>
                                        </fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                            </fo:table-body>
                        </fo:table>
                    </fo:block>
                </fo:flow>
            </fo:page-sequence>
        </fo:root>
    </xsl:template>

</xsl:stylesheet>
